<!DOCTYPE html>
<html>
<head>
<div th:include="base-libs :: base-libs" />
<title>卫生局月报</title>


<meta name="content-type" content="text/html; charset=UTF-8">
	<style>
		body {
			background: #fff;
			overflow: hidden;
			text-align: center;
		}
		.laydate-icon{
		    line-height: 28px;
		    background-color: #fff;
		    height: 28px;
		    border: 1px solid #B6B6B6;
		    border-radius: 5px;
		    width:84% !important;
		}
		.titleTd{
			width:22%;
		}
	</style>
	<script>
		$(function(){
			$(this).registerManagerPage({callback: initView});
		})
		
		function initView(){
			
			$("body").on('click','#btnTj',function(){
				//预约方式处理
				getYyfs();
				var params = {
						type: $("#myForm").data("type"),
						ZT: 1
				}
				
				
				if($(".form-control").QuickValidate()){
					//需要入库的百分百字段去除“%”号
					$("#JCJZL2").val($("#JCJZL").val().substring(0,5));
					$("#QYJCJZL2").val($("#QYJCJZL").val().substring(0,5));
					$("#XYNJZL2").val($("#XYNJZL").val().substring(0,5));
					$("#QYXYNJZL2").val($("#QYXYNJZL").val().substring(0,5));
					
					$.QuickRemote.AjaxFiledFormSubmit("myForm", function(result){ 
						if(result.state){
							$.QuickAlert.alertNormal("月报保存成功！", {callback: function(){
								//$("[name=ZTMC]").val('待审核');
								//btnController('remove');
                                queryDataByNowDate()
							}});
						}else{
							var info = result["info"];
							$.QuickAlert.alertFail({content: info["faultInfo"]});
						}
					}, params)
				}
			})
			
			//审核记录
			$("body").on('click','#btnShjl',function(){
				StoreCache.setCache("BBID", $("#ID").val());
				parent.layer.open({
					  type: 2,
					  area: ["60%", "500px"],
					  content: contextRoot + 'wsj/bbShjl.html',
					  scrollbar: false,
					  resize: false,
					  title:'审核记录'
				});
			});
			
			//载入值域：Yyfs
			var yyfsArr = StoreCache.getCache('TB_ZY_YYFS');
			if(!$.isEmptyObject(yyfsArr)){
				var yyfsBox = $("#yyfsBox");
				var inputCss = "width:17px;display:inline-block;float:left";
				$.each(yyfsArr.data, function(i, item){
					var input = $("<input>").attr({style: inputCss, type: 'checkbox', name: 'YYFS_', value: item.XMDM});
					var div = $("<div>").css({'float':'left', 'margin-right': '8px'}).html(item.XMMC);
					yyfsBox.append(input,div)
				})
			}

            initData();
		}
		
		function initData(){
			var date = new Date(),
				NF = date.getFullYear(),
				YF = date.getMonth() + 1;
			if(YF<10) YF = '0' + YF;
			queryDataByNowDate({NF: NF,YF: YF});
		}
		
		/** 通过当前时间查询数据  */
		function queryDataByNowDate(dateObj){
            var config = $.extend({},dateObj);
			if(StringUtils.isEmpty(config.NF)){
                config = getYearAndMonth();
			}
			var queryParams = {
				NF: config.NF,
				YF: config.YF
			}
			var backParams = {
				NFYF: config.NF + '-' + config.YF,
				NF: config.NF
			}
			$.QuickRemote.AjaxJson(contextRoot + "wsjyb/queryOne", queryDataByNowDateBack, queryParams, backParams);
		}
		/** 通过当前时间查询数据--回调  */
		function queryDataByNowDateBack(result, backParams){
			if(StringUtils.isEmpty(result.errInfo)){
				result = $.extend(result,backParams);
				if(result.ZT == 1 || result.ZT == 3){
					//待审核||审核通过
					btnController('remove');
					$("input:not('#NFYF')").attr("disabled",'disabled');
				}else if(result.ZT == 2 || result.ZT == 4){
					//审核不同过
					$("#myForm").data("type","update");
                    $("input:not('#NFYF')").removeAttr("disabled");
                    btnController('add');
				}else{
					$("#myForm").data("type","add");
                    $("input:not('#NFYF')").removeAttr("disabled");
					btnController('add');
				}

				result.ZTMC = '未填报';
                var bbztArr = StoreCache.getCache("TB_ZY_BBZT");
                if(!$.isEmptyObject(bbztArr) && !$.isEmptyObject(bbztArr = bbztArr.data)){
                    $.each(bbztArr, function(i,item){
                        if(item.XMDM == result.ZT){
                            result.ZTMC = item.XMMC;
                            return false;
                        }
                    })
                }

				$(".form-control").each(function(){
					var name = $(this).attr('name');
					$(this).val(result[name]).html(result[name]);
				})
				
				//勾选预约方式
				setYyfs();
				
				//查询年报数据（获取数据算出对应百分比）
				var queryParams = {YLJGID : parent.userInfo.PTJGID, NF : result.NF}
				$.QuickRemote.AjaxJson(contextRoot + "wsjnb/queryNbInfo", function(re){
					//设置keyup事件，计算百分比
					var keyupParamArr = [
		                     ['QYZRS','x','QYL','',re.XQHJRKS],//签约率
		                     ['QYZDRQZS','x','ZDRQQYFGL','',re.ZDRQS],//重点人群签约覆盖率
		                     ['JCJZRC','JZRC','JCJZL'],//基层就诊率
		                     ['QYJCJZRC','JCJZRC','QYJCJZL'],//签约基层就诊率
		                     ['XYNJZRC','JZRC','XYNJZL'],//县域内就诊率
		                     ['QYXYNJZRC','JZRC','QYXYNJZL'],//签约县域内就诊率
		                     ['ZYXZRC','ZYXZLYRC','ZYXZLYL'], //住院下转履约率
		                     ['XZLYRC','XZRC','XZLYL'],	//下转履约率
		                     ['MZSZLYRC','MZSZRC','MZSZLYL'],//门诊上转履约率
		                     ['ZYSZLYRC','ZYSZRC','ZYSZLYL'],//住院上转履约率
					];
					setKeyupFun(keyupParamArr);
				}, queryParams);
			}else{
				$.QuickAlert.alertFail({content: result.errInfo});
			}
		}
		
		/** 按钮控制  */
		function btnController(type){
			if(type == 'add'){
				var btns = $("#btnBox").html();
				$("#south").empty().append($(btns)).show();
			}else{
				$("#south").hide().empty();
			}
			$('body').layout("resize");
		}
		
		/** 预约方式字段处理 */
		function getYyfs(){
			var yyfsArr = [];
			$('input[name=YYFS_]:checked').each(function(){
				yyfsArr.push($(this).val());
			})
			$("#YYFS").val(yyfsArr.join());
		}
		
		/** 载入预约方式  */
		function setYyfs(){
			//清空选中
			$('input[name=YYFS_]').removeAttr("checked");
			
			var yyfsArr = $("#YYFS").val().split(',');
			$.each(yyfsArr, function(i,item){
				$('input[name=YYFS_]').each(function(){
					if($(this).val()==item){
						$(this).prop("checked","checked");
						return false;
					}
				})
			})
		}
		
		/**  获取选择的年份和月份  */
		function getYearAndMonth() {
		    var NF,YF;
			if(StringUtils.isEmpty($dp.cal)){
				var date = new Date();
				NF = date.getFullYear();
				YF = date.getMonth() + 1;
			}else{
				NF = $dp.cal.newdate.y;
				YF = $dp.cal.newdate.M;
			}
			if(YF<10) YF = '0' + YF;
			return {NF: NF,YF: YF};
		}
		
		/** 设置keyup事件  */
		function setKeyupFun(keyupParamArr){
			$.each(keyupParamArr, function(i,item){
				$('#'+item[0]).add('#'+item[1]).keyup(function(){
					percent(item[0], item[1], item[2], item[3], item[4]);
				})
				$('#'+item[0]).trigger('keyup');
			})
		}
		
		/** 
		 *	计算百分百： csId:除数id | bcsId:被除数id | replyId:展示结果的标签id | cs:除数 | bcs:被除数 
		 *		注：当csId与cs（bcsId与bcs）同时存在时，以cs(bcs)为主--也就是直接指定静态的除数（被除数）
		 */
		function percent(csId,bcsId,replyId,cs,bcs){
			var num1 = parseFloat(cs || $("#"+csId).val());
			var num2 = parseFloat(bcs || $("#"+bcsId).val());
			var result;
			if(num1 && num2){
				result = (num1/num2*100).toFixed(2) + "%";
			}
			$("#"+replyId).val(result).html(result);
		}
	</script>
</head>

<body class="easyui-layout">
<form id="myForm" action="save" >
	<div region="north" style="height:60px;border:0;border-bottom:1px solid #ddd">
		<table class="form-table">
			<tr>
				<td class="td-text">审核状态：</td>
				<td class="td-content">
					<input name="ZTMC" class="form-control" readonly="readonly"/>
				</td>
				<td class="td-text">机构名称：</td>
				<td class="td-content">
					<input name="JGMC" class="form-control" readonly="readonly" />
				</td>
				<td class="td-text"><label>月份：</label></td>
				<td class="td-content">
					<input id="NFYF" class="form-control laydate-icon" name="NFYF" onclick="WdatePicker({dateFmt:'yyyy-MM',onpicking:queryDataByNowDate})" 
						quick-config="label:'月份', validateProxy:'notNull'"/>
				</td>
				<td>
					<button id="btnShjl" class="btn btn-info" type="button">审核记录</button>
				</td>
			</tr>
		</table>
	</div>
	<div region="center" border="false">
		<div class="easyui-panel" title="一、家庭医生签约情况" border="false" style="width:99.9%">
			<table class="form-table">
				<tr>
					<td class="td-text titleTd"><label>1.家庭医生团队数：</label></label></td>
					<td class="td-content">
						<input id="ID" name="ID" class="form-control" type="hidden"/>
						<input name="JTYSTDS" class="form-control" 
						quick-config="label:'家庭医生团队数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text titleTd"><label>2.团队家庭医生数：</label></td>
					<td class="td-content">
						<input name="TDJTYSS" class="form-control" 
						quick-config="label:'团队家庭医生数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>3.团队护士数：</label></td>
					<td class="td-content">
						<input name="TDHSS" class="form-control" 
						quick-config="label:'团队护士数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>4.团队多点执业医师数：</label></td>
					<td class="td-content">
						<input name="TDDDZYYSS" class="form-control" 
						quick-config="label:'团队多点执业医师数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>5.签约总人数</label>/本期新增签约人数：</td>
					<td class="td-content">
						<input id="QYZRS" name="QYZRS" class="form-control" style="width:40%;" 
						quick-config="label:'签约总人数', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input name="BQXZQYRS" class="form-control" style="width:40%;" 
						quick-config="label:'本期新增签约人数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>6.签约率：</td>
					<td class="td-content">
						<input id="QYL" readonly="readonly" class="form-control" placeholder="签约总人数/辖区内户籍人口数"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>7.签约重点人群总数</label>/本期新增签约数：</td>
					<td class="td-content">
						<input id="QYZDRQZS" name="QYZDRQZS" class="form-control" style="width:40%;" 
						quick-config="label:'签约重点人群总数', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input name="BQXZZDRQQYS" class="form-control" style="width:40%;" 
						quick-config="label:'本期新增签约数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text">8.重点人群签约覆盖率：</td>
					<td class="td-content">
						<input id="ZDRQQYFGL" readonly="readonly" class="form-control" placeholder="重点人群签约总人数/辖区内重点人群数"/>
					</td>
				</tr>
			</table>
		</div>
		<div class="easyui-panel" title="二、慢病规范化管理情况" border="false" style="width:99.9%">
			<table class="form-table">
				<tr>
					<td class="td-text titleTd"><label>1.高血压患者规范管理数：</label></td>
					<td class="td-content">
						<input name="GXYHZGFGLS" class="form-control" 
						quick-config="label:'高血压患者规范管理数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text titleTd"><label>2.糖尿病患者规范管理数：</label></td>
					<td class="td-content">
						<input name="TNBHZGFGLS" class="form-control" 
						quick-config="label:'糖尿病患者规范管理数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>3.高血压签约患者规范管理数：</label></td>
					<td class="td-content">
						<input name="GXYQYHZGFGLS" class="form-control" 
						quick-config="label:'高血压签约患者规范管理数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>4.糖尿病签约患者规范管理数：</label></td>
					<td class="td-content">
						<input name="TNBQYHZGFGLS" class="form-control" 
						quick-config="label:'糖尿病签约患者规范管理数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
			</table>
	
		</div>
	
		<div class="easyui-panel" title="三、就诊及转诊情况" border="false" style="width:99.9%">
			<table class="form-table">
				<tr>
					<td class="td-text titleTd"><label>1.就诊人次：</label></td>
					<td class="td-content">
						<input id="JZRC" name="JZRC" class="form-control" 
						quick-config="label:'就诊人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text titleTd"><label>2.签约就诊人次：</label></td>
					<td class="td-content">
						<input name="QYJZRC" class="form-control" 
						quick-config="label:'签约就诊人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>3.基层就诊人次</label>/签约基层就诊人次：</td>
					<td class="td-content">
						<input id="JCJZRC" name="JCJZRC" class="form-control" style="width:40%;" 
						quick-config="label:'基层就诊人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="QYJCJZRC" name="QYJCJZRC" class="form-control" style="width:40%;" 
						quick-config="label:'签约基层就诊人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>4.县域内就诊人次</label>/签约县域内就诊人次：</td>
					<td class="td-content">
						<input id="XYNJZRC" name="XYNJZRC" class="form-control" style="width:40%;" 
						quick-config="label:'县域内就诊人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="QYXYNJZRC" name="QYXYNJZRC" class="form-control" style="width:40%;" 
						quick-config="label:'签约县域内就诊人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>5.基层就诊率：</label></td>
					<td class="td-content">
						<input id="JCJZL" readonly="readonly" class="form-control" placeholder="基层就诊人次/就诊人次"
						quick-config="label:'基层就诊率', validateProxy:'notNull length', length: '10'"/>
						<input name="JCJZL" id="JCJZL2" class="form-control" style="display:none"/>
					</td>
					<td class="td-text"><label>6.签约基层就诊率：</label></td>
					<td class="td-content">
						<input id="QYJCJZL" readonly="readonly" class="form-control" placeholder="签约基层就诊人次/基层就诊人次"
						quick-config="label:'签约基层就诊率', validateProxy:'notNull length', length: '10'"/>
						<input name="QYJCJZL" id="QYJCJZL2" class="form-control" style="display:none"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>7.县域内就诊率：</label></td>
					<td class="td-content">
						<input id="XYNJZL" readonly="readonly" class="form-control" placeholder="县域内就诊人次/就诊人次"
						quick-config="label:'县域内就诊率', validateProxy:'notNull length', length: '10'"/>
						<input name="XYNJZL" id="XYNJZL2" class="form-control" style="display:none"/>
					</td>
					<td class="td-text"><label>8.签约县域内就诊率：</label></td>
					<td class="td-content">
						<input id="QYXYNJZL" readonly="readonly" class="form-control" placeholder="签约县域内就诊人次/就诊人次"
						quick-config="label:'签约县域内就诊率', validateProxy:'notNull length', length: '10'"/>
						<input name="QYXYNJZL" id="QYXYNJZL2" class="form-control" style="display:none"/>
					</td>
				</tr>
				<tr>
					<td class="td-text" style="vertical-align:middle"><label>9.预约人次：</label></td>
					<td class="td-content" style="vertical-align:middle">
						<input name="YYRC" class="form-control" 
						quick-config="label:'预约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text" style="vertical-align:middle">
						<label>10.预约方式：</label>
						<input class="form-control"  name="YYFS" id="YYFS"  style="display:none" hidden="hidden"
						quick-config="label:'预约方式', validateProxy:'notNull'" cacheTable="TB_ZY_YYFS"/>
					</td>
					<td class="td-content" style="vertical-align:middle" id="yyfsBox">
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>11.住院下转人次</label>/住院下转履约人次：</td>
					<td class="td-content">
						<input id="ZYXZRC" name="ZYXZRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院下转人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="ZYXZLYRC" name="ZYXZLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院下转履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>12.住院下转履约率：</label></td>
					<td class="td-content">
						<input id="ZYXZLYL" readonly="readonly" class="form-control" placeholder="住院下转履约人次/住院下转人次"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>13.下转人次 </label>/下转履约人次：</td>
					<td class="td-content">
						<input id="XZRC" name="XZRC" class="form-control" style="width:40%;" 
						quick-config="label:'下转人次 ', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="XZLYRC" name="XZLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'下转履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>14.下转履约率：</label></td>
					<td class="td-content">
						<input id="XZLYL" readonly="readonly" class="form-control" placeholder="下转履约人次/下转人次"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>15.门诊上转人次</label>/门诊上转履约人次：</td>
					<td class="td-content">
						<input id="MZSZRC" name="MZSZRC" class="form-control" style="width:40%;" 
						quick-config="label:'门诊上转人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="MZSZLYRC" name="MZSZLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'门诊上转履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text">16.门诊上转履约率：</td>
					<td class="td-content">
						<input id="MZSZLYL" readonly="readonly" class="form-control" placeholder="门诊上转履约人次/门诊上转人次"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>17.住院上转人次</label>/住院上转履约人次：</td>
					<td class="td-content">
						<input id="ZYSZRC" name="ZYSZRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院上转人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="ZYSZLYRC" name="ZYSZLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院上转履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text">18.住院上转履约率：</td>
					<td class="td-content">
						<input id="ZYSZLYL" readonly="readonly" class="form-control" placeholder="住院上转履约人次/住院上转人次"/>
					</td>
				</tr>
			</table>
		</div>
		<div class="easyui-panel" title="四、医联体建设情况" border="false" style="width:99.9%">
			<table class="form-table">
			<tr>
				<td class="td-text titleTd"><label>1.下派医生总人数：</label></td>
				<td class="td-content">
					<input name="XPYSZRS" class="form-control" 
					quick-config="label:'下派医生总人数', validateProxy:'notNull length num', length: '10'"/>
				</td>
				<td class="td-text titleTd"><label>2.下派医生总天数：</label></td>
				<td class="td-content">
					<input name="XPYSZTS" class="form-control" 
					quick-config="label:'下派医生总天数', validateProxy:'notNull length num', length: '10'"/>
				</td>
			</tr>
			<tr>
				<td class="td-text"><label>3.下派医生门诊总人次：</label></td>
				<td class="td-content">
					<input name="XPYSMZZRC" class="form-control" 
					quick-config="label:'下派医生门诊总人次', validateProxy:'notNull length num', length: '10'"/>
				</td>
				<td class="td-text"><label>4.下派医生手术总人次：</label></td>
				<td class="td-content">
					<input name="XPYSSSZRC" class="form-control" 
					quick-config="label:'下派医生手术总人次', validateProxy:'notNull length num', length: '10'"/>
				</td>
			</tr>
			<tr>
				<td class="td-text"><label>5.下派医生查房总次数：</label></td>
				<td class="td-content">
					<input name="XPYSCFZCS" class="form-control" 
					quick-config="label:'下派医生查房总次数', validateProxy:'notNull length num', length: '10'"/>
				</td>
				<td class="td-text"><label>6.接收进修人数：</label></td>
				<td class="td-content">
					<input name="JSJXRS" class="form-control" 
					quick-config="label:'接收进修人数', validateProxy:'notNull length num', length: '10'"/>
				</td>
			</tr>
			<tr>
				<td class="td-text"><label>7.举办讲座次数：</label></td>
				<td class="td-content">
					<input name="JBJZCS" class="form-control" 
					quick-config="label:'举办讲座次数', validateProxy:'notNull length num', length: '10'"/>
				</td>
				<td class="td-text"><label>8.培训人次：</label></td>
				<td class="td-content">
					<input name="PXRC" class="form-control" 
					quick-config="label:'培训人次', validateProxy:'notNull length num', length: '10'"/>
				</td>
			</tr>
			<tr>
				<td class="td-text"><label>9.联合病房数：</label></td>
				<td class="td-content">
					<input name="LHBFS" class="form-control" 
					quick-config="label:'联合病房数', validateProxy:'notNull length num', length: '10'"/>
				</td>
				<td class="td-text"><label>10.病区床位数：</label></td>
				<td class="td-content">
					<input name="BQCWS" class="form-control" 
					quick-config="label:'病区床位数', validateProxy:'notNull length num', length: '10'"/>
				</td>
			</tr>
			</table>
	
		</div>
	</div>
</form>	
	<div region="south" id="south" style="height:45px;line-height:40px;text-align:center;border:0;border-top:1px solid #ddd">
		<div style=" margin:0 auto">
			<button id="btnJy" class="btn btn-info" type="button">提交</button>
			<button id="btnXy" class="btn btn-info" type="button">取消</button>
		</div>
	</div>
</body>
<script type="text/html" id="btnBox">
	<button id="btnTj" class="btn btn-info" type="button">提交</button>
</script>
</html>
